<?php
/**
 * Created by .
 * User: luogan
 * Date: 2021/12/28
 */

declare(strict_types=1);

namespace App\Controller\Api\v1;


use App\Controller\AbstractController;
use App\Service\MenuService;
use App\Validate\Api\MenuValidate;
use Hyperf\Di\Annotation\Inject;
class MenuController extends AbstractController
{

    /**
     * @Inject
     * @var MenuService
     */
    private $menuService;

    /**
     * @Inject
     * @var MenuValidate
     */
    private $menuValidate;

    public function list():string
    {
        $data = $this->parame();
        $this->menuValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->menuService->list($data);
        return success('操作成功',$result);
    }

    public function create():string
    {
        $data = $this->parame();
        $this->menuValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->menuService->create($data);
        return success('操作成功',$result);
    }

    public function update():string
    {
        $data = $this->parame();
        $this->menuValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->menuService->update($data);
        return success('操作成功',$result);
    }

    public function detail():string
    {
        $data = $this->parame();
        $this->menuValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->menuService->detail($data['id']);
        return success('操作成功',$result);
    }

    public function delete():string
    {
        $data = $this->parame();
        $this->menuValidate->scene(__FUNCTION__)->validate($data);
        $result = $this->menuService->delete($data['id']);
        return success('操作成功',$result);
    }
}
